package com.sy.core.service;

import com.sy.core.mapper.SysUserMapper;
import com.sy.core.model.SysUser;
import com.sy.core.model.ZTreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author :Chong.CaiXin
 * @Description :
 * @Date : Created in 13:30 2018/12/7
 */
@Service("sysUserService")
public class SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;

    public List<Map<String, Object>> queryList(Map<String, Object> parms) {
        return sysUserMapper.queryList(parms);
    }

    public void update(SysUser pro) {
        sysUserMapper.updateByPrimaryKeySelective(pro);
    }

    public void insert(SysUser pro) {
        sysUserMapper.insertSelective(pro);
    }

    public void delete(String userId) {
        sysUserMapper.deleteByPrimaryKey(userId);
    }

    public SysUser findUserByPk(String userId) {
        return sysUserMapper.selectByPrimaryKey(userId);
    }

    public SysUser queryUserByPhone(Map<String,Object> map) {
        SysUser sys = sysUserMapper.queryUserByPhone(map);
        return sys!=null?sys:null;
    }

    public SysUser authentication(SysUser sysUser) {
        SysUser sys = sysUserMapper.authentication(sysUser);
        return sys!=null?sys:null;
    }

    /**
     * 获取用户下拉选项专用
     * @return
     */
    public List<Map<String, Object>> queryUserChosen() {
        return sysUserMapper.queryUserChosen();
    }

    public List<ZTreeNode> selectUserTreeNode() {
        return sysUserMapper.selectUserTreeNode();
    }

    public SysUser selectUserByAccount(String account) {
        return sysUserMapper.selectUserByAccount(account);
    }

    public SysUser authenticationByAccountAndPasss(String account, String password) {
        return sysUserMapper.authenticationByAccountAndPasss(account,password);
    }
}
